import sys
sys.path.append("lib/pygresql")
import pg

try:
    pgdb_conn = pg.connect(dbname = 'python', host = 'openfire4',\
                             user = 'python', passwd = 'dhu111')
except Exception, e:
    print e.args[0]
    exit()    
'''
st = "insert into test(name) values('ldh')"
try:
    pgdb_conn.query(st)

except Exception, e:
    print e.args[0]
    pgdb_conn.close()
    exit()
'''
st = "select * from test"
try:
     rows =  pgdb_conn.query(st).dictresult()
     print rows[0]['name']
    '''
     for rows in  pgdb_conn.query(st).dictresult():
        print rows
    '''
except Exception, e:
    print e.args[0]
    exit()

pgdb_conn.close()
